package main

import (
	"fmt"
)

type link struct {
	v int
	n *link
}

func (l *link) sum() int {
	if l == nil {
		return 0
	}
	return l.v + l.n.sum()
}

func (l *link) appendNode(s []int) {
	for _, v := range s {
		l.v = v
		next := new(link)
		l.n = next
		l = next
	}
}

func New() *link {
	return new(link)
}

func main() {
	link0 := New()
	link0.appendNode([]int{1, 2, 3, 4, 5})
	fmt.Println(link0.sum())
}
